<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Creates a new service entry in the SCM database</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.win32-create-service" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">win32_create_service</h1>
  <p class="verinfo">(PECL win32service &gt;=0.1.0)</p><p class="refpurpose"><span class="refname">win32_create_service</span> &mdash; <span class="dc-title">Creates a new service entry in the SCM database</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.win32-create-service-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>win32_create_service</strong></span>
    ( <span class="methodparam"><span class="type">array</span> <code class="parameter">$details</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$machine</code></span>
  ] ) : <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
   Attempts to add a service into the SCM database. Administrative
   privileges are required for this to succeed.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.win32-create-service-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">details</code></dt>

     <dd>

      <p class="para">
       An array of service details:
       <dl>

        
         <dt>
<code class="parameter">service</code></dt>

         <dd>

          <p class="para">
           The short name of the service.  This is the name that you
           will use to control the service using the <em>net</em>
           command.  The service must be unique (no two services can share the
           same name), and, ideally, should avoid having spaces in the name.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">display</code></dt>

         <dd>

          <p class="para">The display name of the service.  This is the name that you
          will see in the Services Applet.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">description</code></dt>

         <dd>

          <p class="para">The long description of the service.  This is the description
          that you will see in the Services Applet.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">user</code></dt>

         <dd>

          <p class="para">
           The name of the user account under which you want the service to
           run.  If omitted, the service will run as the LocalSystem account.
           If the username is specified, you must also provide a password.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">password</code></dt>

         <dd>

          <p class="para">
           The password that corresponds to the <code class="parameter">user</code>.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">path</code></dt>

         <dd>

          <p class="para">
           The full path to the executable module that will be launched when
           the service is started.  If omitted, the path to the current PHP
           process will be used.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">params</code></dt>

         <dd>

          <p class="para">
           Command line parameters to pass to the service when it starts.
           If you want to run a PHP script as the service, then the first
           parameter should be the full path to the PHP script that you intend
           to run. If the script name or path contains spaces, then wrap the
           full path to the PHP script with <em>&quot;</em>.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">load_order</code></dt>

         <dd>

          <p class="para">
           Controls the load_order.  This is not yet fully supported.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">svc_type</code></dt>

         <dd>

          <p class="para">
           Sets the service type.  If omitted, the default value is
           <strong><code>WIN32_SERVICE_WIN32_OWN_PROCESS</code></strong>.
           Don&#039;t change this unless you know what you&#039;re doing.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">start_type</code></dt>

         <dd>

          <p class="para">
           Specifies how the service should be started.  The default is
           <strong><code>WIN32_SERVICE_AUTO_START</code></strong> which means the
           service will be launched when the machine starts up.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">error_control</code></dt>

         <dd>

          <p class="para">
           Informs the SCM what it should do when it detects a problem with
           the service.  The default is
           <strong><code>WIN32_SERVER_ERROR_IGNORE</code></strong>.  Changing this
           value is not yet fully supported.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">delayed_start</code></dt>

         <dd>

          <p class="para">
           If <code class="parameter">delayed_start</code> is set to <strong><code>TRUE</code></strong>, then this
           will inform the SCM that this service should be started after other
           auto-start services are started plus a short delay.
          </p>
          <p class="para">
           Any service can be marked as a delayed auto-start service; however,
           this setting has no effect unless the service&#039;s
           <code class="parameter">start_type</code> is
           <strong><code>WIN32_SERVICE_AUTO_START</code></strong>.
          </p>
          <p class="para">
           This setting is only applicable on Windows Vista and Windows Server
           2008 or greater.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">base_priority</code></dt>

         <dd>

          <p class="para">
           To reduce the impact on processor utilisation, it may be necessary
           to set a base priority lower than normal.
          </p>
          <p class="para">
           The <code class="parameter">base_priority</code> can be set to one of the
           constants define in
           <a href="win32service.constants.basepriorities.html" class="link">Win32 Base Priority Classes</a>.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">dependencies</code></dt>

         <dd>

          <p class="para">
           To define the dependencies for your service, it may be necessary to set 
           this parameter to the list of the services names in an array.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">recovery_delay</code></dt>

         <dd>

          <p class="para">
           This parameter defines the delay between the fail and the execution 
           of recovery action. The value is in milliseconds.
          </p>
          <p class="para">
           The default value is 60000.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">recovery_action_1</code></dt>

         <dd>

          <p class="para">
           The action will be executed on first failure. The default value is 
           <strong><code>WIN32_SC_ACTION_NONE</code></strong>.
          </p>
          <p class="para">
           The <code class="parameter">recovery_action_1</code> can be set to one of the
           constants defined in
           <a href="win32service.constants.recovery_action.html" class="link">Win32 Recovery action</a>.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">recovery_action_2</code></dt>

         <dd>

          <p class="para">
           The action will be executed on second failure. The default value is 
           <strong><code>WIN32_SC_ACTION_NONE</code></strong>.
          </p>
          <p class="para">
           The <code class="parameter">recovery_action_2</code> can be set to one of the
           constants defined in
           <a href="win32service.constants.recovery_action.html" class="link">Win32 Recovery action</a>.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">recovery_action_3</code></dt>

         <dd>

          <p class="para">
           The action will be executed on next failures. The default value is 
           <strong><code>WIN32_SC_ACTION_NONE</code></strong>.
          </p>
          <p class="para">
           The <code class="parameter">recovery_action_3</code> can be set to one of the
           constants defined in
           <a href="win32service.constants.recovery_action.html" class="link">Win32 Recovery action</a>.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">recovery_reset_period</code></dt>

         <dd>

          <p class="para">
           The failure count will be reset after the delay defined in the parameter. The delay is expirement in seconds.
          </p>
          <p class="para">
           The default value is <em>86400</em>.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">recovery_enabled</code></dt>

         <dd>

          <p class="para">
           Set this parameter at <strong><code>TRUE</code></strong> to enable the recovery settings, <strong><code>FALSE</code></strong> 
           to disable. 
          </p>
          <p class="para">
           The default value is <strong><code>FALSE</code></strong>
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">recovery_reboot_msg</code></dt>

         <dd>

          <p class="para">
           Set this parameter to define the message saved into the Windows Event 
           Log before the reboot. Used only if one action is set to 
           <strong><code>WIN32_SC_ACTION_REBOOT</code></strong>.
          </p>
         </dd>

        
        
         <dt>
<code class="parameter">recovery_command</code></dt>

         <dd>

          <p class="para">
           Set this parameter to define the command executed when one action is defined on  
           <strong><code>WIN32_SC_ACTION_RUN_COMMAND</code></strong>.
          </p>
         </dd>

        
       </dl>

      </p>
     </dd>

    
    
     <dt>
<code class="parameter">machine</code></dt>

     <dd>

      <p class="para">
       The optional machine name on which you want to create a service.
       If omitted, it will use the local machine.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.win32-create-service-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
    成功时返回 <strong><code>WIN32_NO_ERROR</code></strong>，参数错误时返回 <strong><code>FALSE</code></strong>，或失败时返回一个 <a href="win32service.constants.errors.html" class="link">Win32 错误码</a>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.win32-create-service-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-6458">
    <p><strong>Example #1 A <span class="function"><strong>win32_create_service()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     Create a service with the short name &#039;dummyphp&#039;.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$x&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">win32_create_service</span><span style="color: #007700">(array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'service'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'dummyphp'</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;the&nbsp;name&nbsp;of&nbsp;your&nbsp;service<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'display'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'sample&nbsp;dummy&nbsp;PHP&nbsp;service'</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;short&nbsp;description<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'description'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'This&nbsp;is&nbsp;a&nbsp;dummy&nbsp;Windows&nbsp;service&nbsp;created&nbsp;using&nbsp;PHP.'</span><span style="color: #007700">,&nbsp;</span><span style="color: #FF8000">//&nbsp;long&nbsp;description<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'params'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'"'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">__FILE__&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">'"&nbsp;&nbsp;run'</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;path&nbsp;to&nbsp;the&nbsp;script&nbsp;and&nbsp;parameters<br /></span><span style="color: #007700">));<br /></span><span style="color: #0000BB">debug_zval_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$x</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
     </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-6459">
    <p><strong>Example #2 A <span class="function"><strong>win32_create_service()</strong></span> example with dependencies</strong></p>
    <div class="example-contents"><p>
     Create a service with the short name &#039;dummyphp&#039; and dependencies.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$x&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">win32_create_service</span><span style="color: #007700">(array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'service'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'dummyphp'</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;the&nbsp;name&nbsp;of&nbsp;your&nbsp;service<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'display'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'sample&nbsp;dummy&nbsp;PHP&nbsp;service'</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;short&nbsp;description<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'description'&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'This&nbsp;is&nbsp;a&nbsp;dummy&nbsp;Windows&nbsp;service&nbsp;created&nbsp;using&nbsp;PHP.'</span><span style="color: #007700">,&nbsp;</span><span style="color: #FF8000">//&nbsp;long&nbsp;description<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'params'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'"'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">__FILE__&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">'"&nbsp;&nbsp;run'</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;path&nbsp;to&nbsp;the&nbsp;script&nbsp;and&nbsp;parameters<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'dependencies'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(</span><span style="color: #DD0000">"Netman"</span><span style="color: #007700">),&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;The&nbsp;list&nbsp;of&nbsp;the&nbsp;dependencies&nbsp;<br /></span><span style="color: #007700">));<br /></span><span style="color: #0000BB">debug_zval_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$x</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
     </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example.com1">
    <p><strong>Example #3 A <span class="function"><strong>win32_create_service()</strong></span> example with recovery</strong></p>
    <div class="example-contents"><p>
     Create a service with the short name &#039;dummyphp&#039; and recovery settings.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$x&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">win32_create_service</span><span style="color: #007700">(array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'service'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'dummyphp'</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;the&nbsp;name&nbsp;of&nbsp;your&nbsp;service<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'display'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'sample&nbsp;dummy&nbsp;PHP&nbsp;service'</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;short&nbsp;description<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'description'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'This&nbsp;is&nbsp;a&nbsp;dummy&nbsp;Windows&nbsp;service&nbsp;created&nbsp;using&nbsp;PHP.'</span><span style="color: #007700">,&nbsp;</span><span style="color: #FF8000">//&nbsp;long&nbsp;description<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'params'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'"'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">__FILE__&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">'"&nbsp;&nbsp;run'</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;path&nbsp;to&nbsp;the&nbsp;script&nbsp;and&nbsp;parameters<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'recovery_delay'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">120000</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Recovery&nbsp;action&nbsp;is&nbsp;executed&nbsp;after&nbsp;2&nbsp;minutes<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'recovery_action_1'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">WIN32_SC_ACTION_RESTART</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;On&nbsp;first&nbsp;failure,&nbsp;restart&nbsp;the&nbsp;service<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'recovery_action_2'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">WIN32_SC_ACTION_RUN_COMMAND</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;On&nbsp;second&nbsp;failure,&nbsp;execute&nbsp;the&nbsp;commmand<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'recovery_action_3'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">WIN32_SC_ACTION_NONE</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;On&nbsp;other&nbsp;failure,&nbsp;do&nbsp;nothing<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'recovery_reset_period'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">86400</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Reset&nbsp;the&nbsp;fail&nbsp;counter&nbsp;after&nbsp;1&nbsp;day<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'recovery_enabled'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Enable&nbsp;the&nbsp;recovery&nbsp;parameter<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'recovery_reboot_msg'&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">null</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Do&nbsp;not&nbsp;define&nbsp;a&nbsp;reboot&nbsp;message,&nbsp;it's&nbsp;not&nbsp;needed&nbsp;here<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'recovery_command'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"c:\clean-service.bat"</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;When&nbsp;the&nbsp;action&nbsp;is&nbsp;WIN32_SC_ACTION_RUN_COMMAND,&nbsp;execute&nbsp;this&nbsp;command<br /></span><span style="color: #007700">));<br /></span><span style="color: #0000BB">debug_zval_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$x</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
     </div>

   </div>
  </p>
 </div>



 <div class="refsect1 changelog" id="refsect1-function.win32-create-service-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>0.4.0</td>
       <td>
        The <code class="parameter">dependencies</code>, <code class="parameter">recovery_delay</code>,
        <code class="parameter">recovery_action_1</code>, <code class="parameter">recovery_action_2</code>,
        <code class="parameter">recovery_action_3</code>, <code class="parameter">recovery_reset_period</code>,
        <code class="parameter">recovery_enabled</code>, <code class="parameter">recovery_reboot_msg</code>
        and <code class="parameter">recovery_command</code> parameters have been added.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.win32-create-service-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="win32_delete_service.html" class="function" rel="rdfs-seeAlso">win32_delete_service()</a> - Deletes a service entry from the SCM database</span></li>
    <li class="member"><a href="win32service.constants.basepriorities.html" class="link">Win32 Base Priority Classes</a></li>
    <li class="member"><a href="win32service.constants.recovery_action.html" class="link">Win32 Recovery action</a></li>
    <li class="member"><a href="win32service.constants.errors.html" class="link">Win32 Error Codes</a></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>